package com.dormitory.Servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.dormitory.dao.selectInformation;
@WebServlet("/addStudent")
public class addStudent extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
       String id=req.getParameter("id");
       String name=req.getParameter("name");
       String sex=req.getParameter("sex");
       String spno=req.getParameter("spno");
       String classn=req.getParameter("classn");
       String building=req.getParameter("building");
       String buildingnub=req.getParameter("buildingnub");
       String fudao=req.getParameter("fudao");
       String state=req.getParameter("state");
       selectInformation selectInformation =new selectInformation();
       selectInformation.postStudent("insert into student values('" +id+ "','" +name+ "','"+sex+"','"+spno+"','" +classn+"','"+building+"','"+buildingnub+"','"+fudao+"','"+state+"')");
       }
    }

